//
//  CZCarGroup.m
//  11-汽车品牌列表
//
//  Created by Apple on 16/2/26.
//  Copyright © 2016年 itcast. All rights reserved.
//

#import "CZCarGroup.h"
#import "CZCar.h"

@implementation CZCarGroup


-(instancetype)initWithDict:(NSDictionary *)dict{

    if (self=[super init]) {

        [self setModel:dict[@"model"]];

        [self setHeader:dict[@"header"]];
    }
    return self;

}

-(void)setModel:(NSArray *)model{
    _model = model;
    
    NSMutableArray *nmArray = [NSMutableArray array];
    //2. 遍历字典数组
    for (NSDictionary *dict in _model) {
        CZCar *car = [CZCar carWithDict:dict];
        
        [nmArray addObject:car];
    }
    //3. 将存放为模型对象的数组,赋值给存放字典对象的数组
    _model = nmArray;

}


+ (instancetype)carGroupWithDict:(NSDictionary *)dict{
 
    return [[self alloc]initWithDict:dict];

}

@end
